//模糊匹配卡券码
export function matchCardCode(str) {
  // let str = 'https://qr.test.kudianvip.com/a/00WR5HRi/cp2_81285515044656423483';
  //是卡or券  type:1 券  2 是卡
  if (str.includes('/a/') && str.includes('/c')) {
    //券
    if (str.includes('/cp2_')) {
      //找出券id
      let index = str.indexOf("/cp2_");
      index = index + 5;
      let id = str.substring(index, str.length);
      return { id: id, type: 1 }
    } else if (str.includes('/cd2_')) {//卡
      let index = str.indexOf("/cd2_");
      index = index + 5;
      let id = str.substring(index, str.length);
      return { id: id, type: 2 }
    }
  }
  return null;
}
/*函数防抖*/
export function debounce(fn, interval) {
  console.log("123")
  var timer;
  var gapTime = interval || 1000; //间隔时间 不传值默认为1000ms
  return function () {
    clearTimeout(timer);
    var that = this;
    var args = arguments; //保存arguments setTimeout是全局的 arguments不是防抖函数需要的
    timer = setTimeout(function () {
      fn.call(that, args);
    }, gapTime);
  };
}